package com.deparse.mydialog.animation;

import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;

import com.deparse.mydialog.R;
import com.deparse.mydialog.common.BaseActivity;

/**
 * Created by Administrator on 2016/7/18.
 */
public class AlphaScalexyAnimationActivity extends BaseActivity {
    private ImageView image_flip;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_flip_animation);
        image_flip = (ImageView) findViewById(R.id.image_flip);
        image_flip.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ObjectAnimator anim = ObjectAnimator//
                        .ofFloat(image_flip, "zhy", 1.0F, 0.0F, 1.0F)//
                        .setDuration(1000);//
                anim.start();
                anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                    @Override
                    public void onAnimationUpdate(ValueAnimator animation) {
                        float cVal = (Float) animation.getAnimatedValue();
                        image_flip.setAlpha(cVal);
                        image_flip.setScaleX(cVal);
                        image_flip.setScaleY(cVal);
                    }
                });
            }
        });

    }
}
